Ext.define('StaffServer.view.sysRole.ChooseResourceTree', {
	requires : ['StaffServer.store.RoleResourceTreeStore'],

	extend : 'Ext.tree.Panel',
	alias : 'widget.chooseResourceTree',
	store : "RoleResourceTreeStore",
	split : true,
	autoScroll : true,
	animate : true,
	containerScroll : true,
	collapsible : true,
	rootVisible : true,

	listeners : {
    	checkchange: function(node,checked,eOpts){
	        if (checked) {
	        	node.bubble(function(parentNode) {
	           		parentNode.set('checked', true);
	        	});
      			node.cascadeBy(function(node) {
       				node.set('checked', true);
          		});
         	} else {
           		node.cascadeBy(function(node) {
           			node.set('checked', false);
            	});
           		node.bubble(function(parentNode) {
	             	var isSiblingCheck = false;
	             	parentNode.eachChild(function(childNode){
	             	if(childNode.get('checked'))
	            		isSiblingCheck=true;
	              	});
            		parentNode.set('checked', isSiblingCheck);
             	});
         	}
		}
	}
});